package com.xmtlxx.system.mapper;

import com.xmtlxx.common.annotation.DataColumn;
import com.xmtlxx.common.annotation.DataPermission;
import com.xmtlxx.common.core.domain.entity.SysDept;
import com.xmtlxx.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 部门管理 数据层
 *
 * @author xmtlxx
 */
public interface SysDeptMapper extends BaseMapperPlus<SysDeptMapper, SysDept, SysDept> {

    /**
     * 查询部门管理数据
     *
     * @param dept 部门信息
     * @return 部门信息集合
     */
    @DataPermission({
        @DataColumn(key = "tenantName", value = "d.create_by"),
        @DataColumn(key = "deptName", value = "d.dept_id")
    })
    List<SysDept> selectDeptList(SysDept dept);

    @DataPermission({
        @DataColumn(key = "tenantName", value = "d.create_by"),
//        @DataColumn(key = "deptName", value = "d.dept_id")
    })
    List<SysDept> treeDeptList(SysDept dept);

    /**
     * 根据角色ID查询部门树信息
     *
     * @param roleId            角色ID
     * @param deptCheckStrictly 部门树选择项是否关联显示
     * @return 选中部门列表
     */
    List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);

    /**
     * 修改子元素关系
     *
     * @param depts 子元素
     * @return 结果
     */
    int updateDeptChildren(@Param("depts") List<SysDept> depts);

    @DataPermission({
        @DataColumn(key = "tenantName", value = "d.create_by"),
        @DataColumn(key = "deptName", value = "d.dept_id")
    })
    Map<String,Object> selectCountDepts();

    List<String> selectDeptCodesByRoleIds(@Param("deptId") Long deptId,@Param("parentId") Long parentId,@Param("roleIds") List<Long> roleIds,@Param("tenantId") Long tenantId);


    String getAreaName(@Param("deptId") Long deptId);

}
